﻿using System;
using Microsoft.AspNetCore.Mvc;
using VegetableSale.NET.Entities;
using VegetableSale.NET.Entities.EGooden;
using VegetableSale.NET.Services;

namespace VegetableSale.NET.Controllers;

[ApiController]
[Route("api/[Action]")]
public class GoodController : Controller {

    private GoodService goodService = new GoodService();

    [HttpPost(Name = "goodlist")]
    public Result goodlist([FromBody] QueryDTO queryDTO)
    {
        return goodService.getGoodList(queryDTO);
    }

    [HttpPost(Name = "goodAllGood")]
    public CountResult goodAllGood()

    {
        return goodService.getAllGood();
    }

    [HttpPost(Name = "goodadd")]
    public Result goodadd([FromBody] GoodQuery goodQuery)
    {
        return goodService.addGood(goodQuery);
    }

    [HttpPost(Name = "gooddelete")]
    public Result gooddelete(int commid)
    {
        return goodService.deleteGood(commid);
    }

    [HttpPost(Name = "goodupdate")]
    public Result goodupdate(Gooden gooden)
    {
        return goodService.updateGood(gooden);
    }

}

